

namespace IQIGame.Onigao.GamePlay
{
    public static class LevelEntityFactory
    {
        public static LevelPlayBaseEntity CreateEntity(DynLevelEntity levelEntity)
        {
            //没有真实实体配置表，那就是虚拟实体
            if (levelEntity.cfgLevelEntity == null)
            {
                return LevelVirutalEntity.CreateEntity(levelEntity);
            }
            else
            {
                return LevelNormalEntity.CreateEntity(levelEntity);
            }
        }

        public static LevelCharacterEntity CreateEntity(DynLevelHeroEntity dynHeroEntity)
        {
            var levelPlay = LevelPlayModule.Instance.levelPlay;
            if (levelPlay.players.TryGetValue(dynHeroEntity.playerId, out var player))
            {
                bool isMine = dynHeroEntity.playerId == levelPlay.levelPlayer.id;
                return LevelCharacterEntity.CreateEntity(dynHeroEntity, player.GetLeaderHero(), isMine);
            }
            return null;
        }
    }
}
